package com.wanxi.company.controller;


import com.wanxi.common.entity.CompanyModel;
import com.wanxi.common.result.ResultDTO;
import com.wanxi.company.service.impl.CompanyServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

//@Controller
@RestController
@Api(tags = "公司管理",value = "公司Open api 入口")
public class CompanyController {
    @Autowired
    private CompanyServiceImpl companyService;


    @RequestMapping("/back/company/findAll")
    @ApiOperation(value = "查询所有公司",response = ResultDTO.class,httpMethod = "GET")
//    @ResponseBody
    public ResultDTO findAll(CompanyModel company) {
        ResultDTO resultDTO = companyService.findAll(company);
        return resultDTO;
    }



    @RequestMapping("/back/company/add")
    @ApiOperation(value = "新增公司",response = ResultDTO.class,httpMethod = "POST")
//    @ResponseBody
    public ResultDTO add(CompanyModel company) {

        ResultDTO resultDTO = companyService.add(company);
        return resultDTO;
    }


    @RequestMapping("/back/company/delete")
    @ApiOperation(value = "删除公司",response = ResultDTO.class,httpMethod = "POST")
//    @ResponseBody
    public ResultDTO delete(CompanyModel company) {

        ResultDTO resultDTO = companyService.delete(company);
        return resultDTO;
    }


    @RequestMapping("/back/company/findById")
    @ApiOperation(value = "查询公司",response = ResultDTO.class,httpMethod = "GET")
//    @ResponseBody
    public ResultDTO findById(CompanyModel company) {
        ResultDTO resultDTO = companyService.findById(company);
        return resultDTO;
    }


    @RequestMapping("/back/company/update")
    @ApiOperation(value = "更新公司",response = ResultDTO.class,httpMethod = "POST")
//    @ResponseBody
    public ResultDTO update(CompanyModel company) {
        ResultDTO resultDTO = companyService.update(company);
        return resultDTO;
    }


}
